#include "light.h"

Light::Light(bool spot)
{
  options_ = NULL;
  spot_ = spot;
  active = false;
  changed = false;
  x = 0;
  z = 0;
  color[0] = 0;
  color[1] = 0;
  color[2] = 0;
  color[3] = 1;
  ambient[0] = 0;
  ambient[1] = 0;
  ambient[2] = 0;
  ambient[3] = 1;
  position[0] = 0;
  position[1] = 0;
  position[2] = 0;
  position[3] = 1;
  direction[0] = 0;
  direction[1] = 0;
  direction[2] = 0;
  cutoff = 0;
  exponent = 0;
}

Light::~Light()
{
  delete options_;
}

void Light::Switch()
{
  changed = true;
  active = !active;
}

void Light::GenerateLightBox(Point p[])
{
  p[0].x = position[0] - 0.1;
  p[0].y = position[1] - 0.1;
  p[0].z = position[2] - 0.1;
  p[1].x = position[0] + 0.1;
  p[1].y = position[1] + 0.1;
  p[1].z = position[2] + 0.1;
}

void Light::ShowOptions()
{
  if (options_ == NULL) {
    options_ = new LightOptionsWidget(*this, spot_);
  }
  options_->show();
  options_->raise();
}

void Light::HideOptions()
{
  if (options_ != NULL) {
    options_->hide();
  }
}
